package baseFx.common.remote;

import baseFx.common.Assert;

import java.util.ArrayList;
import java.util.List;

public class RemoteFactory {
    private static List<ProxyProvider> providers = new ArrayList<>();

    public static void addProvider(ProxyProvider provider) {
        providers.add(provider);
    }

    public static <T> T get(Class<T> clazz) {
        Assert.isTrue(clazz.isInterface());
        for (ProxyProvider item : providers) {
            T rs = item.get(clazz);
            if (rs != null) {
                return rs;
            }
        }
        return null;
    }
}
